
package dieci.system;

import dieci.database.PersistentObject;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 *
 * @author DuckSys
 */
public class Order implements PersistentObject{

    private Date orderDate;
    private long orderId;
    private Set<OrderDetails> details = new HashSet<>();
    private Supplier supplier;
    private double totalOrderAmount;


    public Order()
    {
    }

    public Order(Supplier supp, Date orderDate, double amount)
    {
        this.supplier = supp;
        this.orderDate = orderDate;
        this.totalOrderAmount = amount;
    }
    
    public Order(Supplier supp, Date orderDate, Set<OrderDetails> details, double amount)
    {
        this(supp, orderDate, amount);
        this.details = details;
    }

    public Order(long id, Supplier supp, Date orderDate, Set<OrderDetails> details, double amount)
    {
        this(supp, orderDate, amount);
        this.details = details;
        this.orderId = id;
    }
    
        /**
     * Get the value of totalOrderAmount
     *
     * @return the value of totalOrderAmount
     */
    public double getTotalOrderAmount()
    {
        return totalOrderAmount;
    }

    /**
     * Set the value of totalOrderAmount
     *
     * @param totalOrderAmount new value of totalOrderAmount
     */
    public void setTotalOrderAmount(double totalOrderAmount)
    {
        this.totalOrderAmount = totalOrderAmount;
    }

    
    /**
     * Get the value of supplierId
     *
     * @return the value of supplierId
     */
    public Supplier getSupplier()
    {
        return supplier;
    }

    /**
     * Set the value of supplierId
     *
     * @param supplierId new value of supplierId
     */
    public void setSupplier(Supplier supplierId)
    {
        this.supplier = supplier;
    }

    

    
    
    /**
     * Get the value of details
     *
     * @return the value of details
     */
    public Set<OrderDetails> getDetails()
    {
        return details;
    }

    /**
     * Set the value of details
     *
     * @param details new value of details
     */
    public void setDetails(Set<OrderDetails> details)
    {
        this.details = details;
    }


    /**
     * Get the value of orderId
     *
     * @return the value of orderId
     */
    public long getOrderId()
    {
        return orderId;
    }

    /**
     * Set the value of orderId
     *
     * @param orderId new value of orderId
     */
    public void setOrderId(long orderId)
    {
        this.orderId = orderId;
    }

    /**
     * Get the value of orderDate
     *
     * @return the value of orderDate
     */
    public Date getOrderDate()
    {
        return orderDate;
    }

    /**
     * Set the value of orderDate
     *
     * @param orderDate new value of orderDate
     */
    public void setOrderDate(Date orderDate)
    {
        this.orderDate = orderDate;
    }

    @Override
    public String toString(){
        SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyy");
        
        return String.valueOf(orderId)+" - " + supplier.getName()+ " - " + df.format(orderDate);
    }
}
